package com.my.chapter18;

import net.mindview.util.TextFile;

import java.util.*;

public class practice17 {
    public static void main(String[] args) {
        Map<Character,Integer> charsStat =
                new HashMap<Character,Integer>();
        for(String word :
                new TextFile(".\\src\\com\\my\\chapter18\\practice17.java", "\\W+"))
            for(int i = 0; i < word.length(); i++) {
                Character ch = word.charAt(i);
                Integer freq = charsStat.get(ch);
                charsStat.put(ch, freq == null ? 1 : freq + 1);
            }
        List<Character> keys = Arrays.asList(
                charsStat.keySet().toArray(new Character[0]));
        for(Character key : keys)
            System.out.println(key + " => " + charsStat.get(key));
    }
}
